#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>

// 声明外部符号
extern int shared_value;
extern int export_add(int a, int b);
extern int export_sub(int a, int b);




// 模块初始化
static int __init math_import_init(void)
{
    int a = 30, b = 10;
    
    printk(KERN_INFO "Math Import Module Loaded\n");
    
    // 使用共享变量
    printk(KERN_INFO "Original shared_value = %d\n", shared_value);
    shared_value += 50;
    printk(KERN_INFO "Modified shared_value = %d\n", shared_value);
    
    // 使用加减函数
    printk(KERN_INFO "%d + %d = %d\n", a, b, export_add(a, b));
    printk(KERN_INFO "%d - %d = %d\n", a, b, export_sub(a, b));
    
    return 0;
}

// 模块退出
static void __exit math_import_exit(void)
{
    printk(KERN_INFO "Math Import Module Unloaded\n");
    printk(KERN_INFO "Final shared_value = %d\n", shared_value);
}

module_init(math_import_init);
module_exit(math_import_exit);



MODULE_LICENSE("GPL");
MODULE_AUTHOR("Your Name");
MODULE_DESCRIPTION("Demonstration of module_param_array usage");